<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/meta.jsp"%>
<script type="text/javascript" src="<c:url value="/common/js/DatePicker/WdatePicker.js"/>" ></script>
<script type="text/javascript" src="<c:url value="/common/js/jquery-validate/jquery.validate.js"/>" ></script>
<title>修改电梯管理</title>
</head>
<body>
	<form id="formId" action='<c:url value="/ssjk/updateDtxx" />' method="post" autocomplete="off" >
		<table class="add_form">
			<tr>
				<td align="right" width="20%">
					<label>注册代码:</label>
				</td>
				<td width="30%">
					<input name="id"  value="<c:out value="${dtxx.id}" />" type="hidden">
					<input name="dtxxZcdm" value="<c:out value="${dtxx.dtxxZcdm}" />" class="required" />
				</td>
				<td align="right" width="20%">
					<label>名称:</label>
				</td>
				<td width="30%">
					<input name="dtxxSbmc" value="<c:out value="${dtxx.dtxxSbmc}" />" class="required" />
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>电梯类别:</label>
				</td>
				<td width="30%">
					<input id="tslbName" name="dtxxTslbname" value="<c:out value="${dtxx.dtxxTslbname}" />" readonly="readonly" onclick="showTslb(this)" />
					<input id="tslbId" type="hidden" name="dtxxTslbid" value="<c:out value="${dtxx.dtxxTslbid}" />" />
				</td>
				<td align="right" width="20%">
					<label>电梯型号:</label>
				</td>
				<td width="30%">
					<input name="dtxxXh" value="<c:out value="${dtxx.dtxxXh}" />" />
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>所在地址:</label>
				</td>
				<td width="30%">
					<input name="dtxxSydz" value="<c:out value="${dtxx.dtxxSydz}" />" class="required" />
				</td>
				<td align="right" width="20%">
					<label>内部编号:</label>
				</td>
				<td width="30%">
					<input name="dtxxDwnbbh" value="<c:out value="${dtxx.dtxxDwnbbh}" />" />
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>制造年月:</label>
				</td>
				<td width="30%">
					<input name="dtxxZzny" value="<fmt:formatDate value="${dtxx.dtxxZzny}" pattern="yyyy-MM-dd"/>" readonly="readonly" class="required"  onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
				</td>
				<td align="right" width="20%">
					<label>出厂编号:</label>
				</td>
				<td width="30%">
					<input name="dtxxCcbh" value="<c:out value="${dtxx.dtxxCcbh}" />" class="required" />
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>适合场合:</label>
				</td>
				<td width="30%">
					<input name="dtxxSych" value="<c:out value="${dtxx.dtxxSych}" />" />
				</td>
				<td align="right" width="20%">
					<label>投用日期:</label>
				</td>
				<td width="30%">
					<input name="dtxxTyrq" value="<fmt:formatDate value="${dtxx.dtxxTyrq}" pattern="yyyy-MM-dd"/>" readonly="readonly" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>使用单位:</label>
				</td>
				<td width="30%">
					<input id="dtxxSydwName" value="<c:out value="${dtxx.dtxxSydwName}" />" readonly="readonly" />
					<input id="dtxxSydwId" value="<c:out value="${dtxx.dtxxSydwid}" />" name="dtxxSydwid" type="hidden" class="required" />
				</td>
				<td align="right" width="20%">
					<label>维保单位:</label>
				</td>
				<td width="30%">
					<input id="dtxxWbdwName" value="<c:out value="${dtxx.dtxxWbdwName}" />" readonly="readonly" />
					<input id="dtxxWbdwId" value="<c:out value="${dtxx.dtxxWbdwId}" />" name="dtxxWbdwId" type="hidden" class="required" />
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>维保站：</label>
				</td>
				<td width="30%">
					<input id="dtxxWbzDz" name="dtxxWbzDz" value="<c:out value="${dtxx.dtxxWbzDz}" />" readonly="readonly" />
					<input id="dtxxWbzId" name="dtxxWbzId" value="<c:out value="${dtxx.dtxxWbzId}" />" type="hidden" />
				</td>
				<td align="right" width="20%">
					<label>维保站电话：</label>
				</td>
				<td width="30%">
					<input name="dtxxWbzDh" id="dtxxWbzDh" value="<c:out value="${dtxx.dtxxWbzDh}" />" readonly="readonly">
				</td>
			</tr>
			<tr>
				<td align="right" width="20%">
					<label>地图标注:</label>
				</td>
				<td colspan="3" width="80%">
					<input name="dtxxMapszdz" id="mapSzdz" value='<c:out value="${dtxx.dtxxMapszdz }" />' class="required" />
				</td>
			</tr>
			<tr>
				<td colspan="4" align="center">
					<input id="submit" type="button" value="保存"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		$(function() {
			var ajax_option = {
				success:function(data) {
					console.log(data);
					if(data.flag == 1) {
						//关闭窗口，刷新父页面
						parent.closeAndRefresh();
						art.dialog.alert(data.msg);
					} else {
						art.dialog.alert(data.msg);
					}
				}
			};
			$("#formId").ajaxForm();
			$("#submit").click(function() {
				var v=$("#formId").valid();
				if(v){
					$("#submit").attr("disabled",true);
				}else{
					return false;
				}
				$("#formId").ajaxSubmit(ajax_option);
				return true;
			});
			
			//选择使用单位
			$("#dtxxSydwName").click(function(){
				art.dialog.open(
					"<c:url value='/sydw/lSelectSydw' />",
					{
						id: "selectSydw",
						title: "选择使用单位",
						lock: true,
						width: 700,
						height: 450,
						close: function () {
							var sydwId = art.dialog.data('sydwId');// 读取使用单位Id
							var sydwName = art.dialog.data('sydwName');// 读取使用单位Name
							$('#dtxxSydwId').val(sydwId);
							$('#dtxxSydwName').val(sydwName);
							art.dialog.removeData('sydwId');
							art.dialog.removeData('sydwName');
						}
					}
				);
			});
			
			//选择维保单位
			$("#dtxxWbdwName").click(function(){
				art.dialog.data('wbdwId',$('#dtxxWbdwId').val());
				art.dialog.data('wbdwName',$('#dtxxWbdwName').val());
				art.dialog.open(
					"<c:url value='/wbdw/lSelectWbdw'/>",
					{
						id: "selectWbdw",
						title: "选择维保单位",
						lock: true,
						width: 700,
						height: 450,
						close: function () {
							var wbdwId = art.dialog.data('wbdwId');// 读取使用单位Id
							var wbdwName = art.dialog.data('wbdwName');// 读取使用单位Name
							if($('#dtxxWbdwId').val()!=wbdwId){
								$('#dtxxWbzId').val("");
								$('#dtxxWbzDz').val("");
								$('#dtxxWbzDh').val("");
							}
							$('#dtxxWbdwId').val(wbdwId);
							$('#dtxxWbdwName').val(wbdwName);
							art.dialog.removeData('wbdwId');
							art.dialog.removeData('wbdwName');
						}
					}
				);
			});
			
			//选择维保站
			$("#dtxxWbzDz").click(function(){
				var wbdwId=$("#dtxxWbdwId").val();
				if(wbdwId==null || wbdwId =="" || $("#dtxxWbdwName").val().length<1){
					art.dialog.alert("请先选择维保单位");
					return false;
				}
				art.dialog.data('wbzId',$('#dtxxWbzId').val());
				art.dialog.data('wbzDz',$('#dtxxWbzDh').val());
				art.dialog.data('wbzDh',$('#dtxxWbzDh').val());
				art.dialog.open(
						"<c:url value='/wbz/FsWbz'/>?wbdwId="+wbdwId,
						{
							id: "selectWbqy",
							title: "选择维保站",
							lock: true,
							width: 700,
							height: 450,
							close: function () {
								var wbzId = art.dialog.data('wbzId');// 读取维保站id
								var wbzDz = art.dialog.data('wbzDz');// 读取维保站地址
								var wbzDh = art.dialog.data('wbzDh');// 读取维保站电话
								$('#dtxxWbzId').val(wbzId);
								$('#dtxxWbzDz').val(wbzDz);
								$('#dtxxWbzDh').val(wbzDh);
								art.dialog.removeData('wbzId');
								art.dialog.removeData('wbzDz');
								art.dialog.removeData('wbzDh');
							}
						}
					);
			});
			
			//地图标注所在地
			$("#mapSzdz").click(function(){
				art.dialog.data("mapSzdz",$("#mapSzdz").val());
				art.dialog.open(
					"<c:url value='/wbdw/mapSelect?mapType=marker'/>",
					{
						id: "mapSelect",
						title: "标注所在地址",
						lock: true,
						width: 1024,
						height: 768,
						close: function () {
							var mapSzdz = art.dialog.data('mapSzdz');// 读取地图标注地址
							$('#mapSzdz').val(mapSzdz);
							art.dialog.removeData('mapSzdz');
						}
					}
				);
			});
		});
	</script>
	<script type="text/javascript" src="<c:url value="/common/js/zd/tslb.js"/>" ></script>
</body>
</html>